# -*- coding: utf-8 -*-
require 'helper'

class TestRegressionTable08 < Test::Unit::TestCase
  def setup
    setup_dir_var
  end

  def teardown
    File.delete(@xlsx) if File.exist?(@xlsx)
  end

  def test_table08
    @xlsx = 'table08.xlsx'
    workbook  = WriteXLSX.new(@xlsx)
    worksheet = workbook.add_worksheet

    # Set the column width to match the taget worksheet.
    worksheet.set_column('C:F', 10.288)

    # Add some strings to order the string table.
    worksheet.write_string('A1', 'Column1')
    worksheet.write_string('B1', 'Column2')
    worksheet.write_string('C1', 'Column3')
    worksheet.write_string('D1', 'Column4')
    worksheet.write_string('E1', 'Total')

    # Add the table.
    worksheet.add_table(
                        'C3:F14',
                        {
                          :total_row => 1,
                          :columns   => [
                                         {:total_string => 'Total'},
                                         {},
                                         {},
                                         {:total_function => 'count'}
                                        ]
                        }
                        )

    workbook.close
    compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
                                [ 'xl/calcChain.xml', '[Content_Types].xml', 'xl/_rels/workbook.xml.rels' ],
                                {  'xl/workbook.xml' => ['<workbookView'] }
                                )
  end
end
